<?php

class IndexController extends Zend_Controller_Action
{
    protected $_logger;
	protected $_baseUrl;
    public function init()
    {
        /* Initialize action controller here */
    }
	public function preDispatch()
	{
	    $this->_logger = Zend_Registry::get( 'logger' );
		$this->_baseUrl = Zend_Registry::get( 'baseUrl' );;
		$this->view->baseUrl = $this->_baseUrl;
	}

    public function indexAction()
    {
		$db = Zend_Registry::get( 'db' );
        $usersTbl = new Model_Table_Users();
        //$test = $db->query( "DELETE FROM user where user_id = 1" );
        //$where = $db->quoteInto( 'user_id = ?', 1 );
        //$usersTbl->delete( $where );
        $all = $usersTbl->findAll();
        Zend_Debug::dump($all);
        
		//$sql = $db->quoteInto( 'delete from user where user_id = ?', 1 );
		//$db->query( $sql );
		/*$userTbl = new Model_Table_Users();
		$where = $db->quoteInto( 'user_id = ?', 1 );
		$userTbl->delete($where);*/

		//$logger = new Zend_Log();
        //$writer = new Zend_Log_Writer_Firebug();
        //$logger->addWriter($writer);
		//$this->_helper->json(123123123);
		//$logger->log($var, Zend_Log::INFO);
        /*$this->_logger->alert(123123123);
		$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
        $profiler->setEnabled(true);*/
        //$db->setProfiler($profiler);
		//$this->_helper->Logger->info($_SERVER);
		//$this->_helper->Logger->info( $this->_request->isXmlHttpRequest() );
        //if ( $this->_request->isXmlHttpRequest() ) {
		//$this->_helper->Logger->info($_SERVER);
		//( isset($_SERVER['HTTP_X_REQUESTED_WITH'] )
	    //  && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
			//$this->_helper->json($this->_request->getParams());
            //$this->_logger->info ( $this->_request->getPost('name') );
			//Zend_Debug::dump(dfsdfsdf);
			//if (1==2)
			   // $this->_helper->json('我是中文');
	        /*$this->_logger->alert ( 'Alert ' );
			$this->_logger->log ( 'Log !', Zend_Log::ERR );
			$this->_logger->err ( 'Error !' );
			$this->_logger->info ( 'Information ' );
			
			$this->_logger->log ( "Emergency !", Zend_Log::EMERG );
			$this->_logger->log ( 'Warning !', Zend_Log::WARN );
			$this->_logger->log ( 'Debug !', Zend_log::DEBUG );
			$this->_logger->log ( 'critical  !', Zend_log::CRIT );
			$this->_logger->log ( 'NOTICE  !', Zend_log::NOTICE );
			$this->_logger->log ( $this->getRequest (), Zend_log::DEBUG );*/
		//} 
    }
    public function helperAction() {
		//$this->_helper->Logger ( "我是helper" );
		//$this->_helper->json('我是helper');
		/*$this->_helper->Logger ( "My Log Via Helper :)", Zend_Log::ALERT );
		$this->_helper->Logger ( $this->getRequest ()->getControllerName (), Zend_Log::DEBUG );
		$this->_helper->Logger ( $this->getRequest ()->getActionName (), Zend_Log::DEBUG );
		
		$this->_helper->Logger->err ( "err Via __call function " );
		$this->_helper->Logger->info ( "info Via __call function " );
		$this->_helper->Logger->warn ( "warning Via __call function " );*/
		
		/* throw an Exception to firebug console 
		 * you should use try catch clause 
		 * this is just example
		 *  @ Zend_Exception Class 
		 */
		//$this->_helper->Logger ( new Zend_Exception ( "Some Error Happen Here " ), Zend_Log::ALERT );
	
	}

}

